package org.chainsale.prefuse.action;

import java.awt.geom.Rectangle2D;

import prefuse.Display;
import prefuse.Visualization;
import prefuse.action.Action;
import prefuse.util.GraphicsLib;
import prefuse.util.display.DisplayLib;

public class ZoomToFitAction extends Action {

	@Override
	public void run(double frac) {
		Rectangle2D bounds = m_vis.getBounds(Visualization.ALL_ITEMS);
		Display display = m_vis.getDisplay(0);
		GraphicsLib.expand(bounds, 50 + (int) (1.0D / display.getScale()));
		DisplayLib.fitViewToBounds(display, bounds, 2000L);
	}

}
